<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>DingDing Admin</title>
    <!-- base:css -->
    <div th:include="includeJs::bootstrap_js"></div>
    <div th:include="includeJs::layui_js"></div>
</head>
<div class="container-scroller d-flex">
    <div th:replace="includeJs::admin_leftNav"></div>

    <div class="container-fluid page-body-wrapper">
        <div th:replace="includeJs::admin_nav"></div>
        <div class="main-panel">
            <div class="container grid-margin stretch-card">
                <div class="card">
                    <div class="card-body row" >
                        <h4  class="col-12 card-title">借贷审核</h4>
                        <form onsubmit="return jiedai()" class="row" th:action="@{/admin/updAduit}" method="post">
                            <input type="hidden" name="lId" th:value="${aduit.l_id}">
                            <input type="hidden" name="userId" th:value="${aduit.user_id}">
                            <div class="form-group">
                                <label>借贷提交时间:</label>
                                <input disabled type="text" th:value="${#dates.format(aduit.order_time, 'yyyy-MM-dd HH:mm:ss')}" name="mName" class="form-control" >
                            </div>
                            <div class="form-group" >
                                <label>申请人</label>
                                <input disabled type="text" th:value="${aduit.real_name}" name="mName" class="form-control" >
                            </div>
                            <div class="form-group">
                                <label>手机号</label>
                                <input disabled type="text" th:value="${aduit.l_phone}" name="mName" class="form-control" >
                            </div>
                            <div class="form-group">
                                <label >身份证号</label>
                                <input disabled type="text" th:value="${aduit.identity_card}" name="mName" class="form-control" id="mName" >
                            </div>
                            <div class="form-group">
                                <label >年龄</label>
                                <input  disabled type="text" th:value="${aduit.age}" name="mName" class="form-control" id="mName" >
                            </div>
                            <div class="form-group">
                                <label>信用分</label>
                                <input th:if="${user.credit<0}" style="color:red;" disabled type="text" th:value="${user.credit}" name="mName" class="form-control"  >
                                <input th:if="${user.credit >= 0 && user.credit <=100}" style="color:#d8a516;" disabled type="text" th:value="${user.credit}" name="mName" class="form-control"  >
                                <input th:if="${user.credit >100}" style="color:#0f971e;" disabled type="text" th:value="${user.credit}" name="mName" class="form-control"  >
                            </div>
                            <div class="form-group">
                                <label for="mName">月收入</label>
                                <input disabled type="text" th:value="${aduit.monthly_profit}" name="mName" class="form-control" >
                            </div>
                            <div class="form-group">
                                <label for="mName">所在公司名称</label>
                                <input disabled type="text" th:value="${aduit.company}" name="mName" class="form-control"  >
                            </div>
                            <div class="form-group">
                                <label for="mName">所在公司电话</label>
                                <input disabled type="text" th:value="${aduit.Company_phone}" name="mName" class="form-control"  >
                            </div>
                            <div class="form-group">
                                <label for="mName">所在地区</label>
                                <input  disabled type="text" th:value="${aduit.address+aduit.street}" name="mName" class="form-control"  >
                            </div>
                            <div th:each="c,index : ${clans}" class="form-group">
                                <label for="mName" th:text="'联系人'+${index.count}+':'+${c.cName}+'('+${c.CRelation}+')'"></label>
                                <input  disabled type="text" th:value="${c.CPhone}" name="mName" class="form-control"  >
                            </div>
                            <div class="form-group">
                                <label >申请借款金额(元)</label>
                                <input readonly type="text" style="color: #bf3322" th:value="${aduit.l_money}" name="lMoney" class="form-control" >
                            </div>
                            <div class="form-group">
                                <label >借款期限(月)</label>
                                <input readonly type="text" th:value="${aduit.l_month}" name="lMonth" class="form-control" >
                            </div>
                            <div class="form-group">
                                <label >年利率(%)</label>
                                <input readonly type="text" th:value="${aduit.interest_rate}" name="interestRate" class="form-control" >
                            </div>
                            <div th:if="${aduit.order_state==T(com.ddf.publics.tool.Constant).LOAN_ORDER_STATE_LOAN_SUCCESS}" class="form-group">
                                <label>每月还款金额</label>
                                <input disabled type="text" th:value="${aduit.Month_money}" name="MonthMoney" class="form-control" >
                            </div>
                            <div th:if="${aduit.loan_type==2}" class="form-group">
                                <label for="gname">担保方式</label>
                                <input disabled type="text" name="month" step="1" th:value="${aduit.gname}" class="form-control" id="gname" >
                            </div>
                            <div class="form-group">
                                <label for="month">借款用途</label>
                                <input disabled type="text" name="month"  th:value="${aduit.purpose_of_loan}" class="form-control" id="month" >
                            </div>
                            <div class="form-group">
                                <label for="month">借款描述</label>
                                <input disabled type="text" name="month"  th:value="${aduit.comment_of_loan}" class="form-control" id="month" >
                            </div>
                            <div class="form-group">
                                <label for="month" >贷款类型:</label>
                                <input disabled class="form-control" type="text" th:value="${aduit.type}" />
                            </div>
                            <div class="form-group col-3">
                                <label>审核</label>
                                <select name="orderState" id="orderState" class="form-control " style="height: 50px;">
                                    <option th:value="${T(com.ddf.publics.tool.Constant).LOAN_ORDER_STATE_NO_PASS}"  th:selected="${aduit.order_state==T(com.ddf.publics.tool.Constant).LOAN_ORDER_STATE_NO_PASS}">不通过</option>
                                    <option th:value="${T(com.ddf.publics.tool.Constant).LOAN_ORDER_STATE_NO_PASS}"  th:selected="${aduit.order_state==T(com.ddf.publics.tool.Constant).NLOAN_ORDER_STATE_CACEL}">用户取消</option>
                                    <option th:value="${T(com.ddf.publics.tool.Constant).LOAN_ORDER_STATE_AUDIT}"  th:selected="${aduit.order_state==T(com.ddf.publics.tool.Constant).LOAN_ORDER_STATE_AUDIT}">审核中</option>
                                    <option th:value="${T(com.ddf.publics.tool.Constant).LOAN_ORDER_STATE_PASS}"  th:selected="${aduit.order_state==T(com.ddf.publics.tool.Constant).LOAN_ORDER_STATE_PASS}">审核通过</option>
                                    <option th:value="${T(com.ddf.publics.tool.Constant).LOAN_ORDER_STATE_LOAN_ING}"  th:selected="${aduit.order_state==T(com.ddf.publics.tool.Constant).LOAN_ORDER_STATE_LOAN_ING}">放款中</option>
                                    <option th:value="${T(com.ddf.publics.tool.Constant).LOAN_ORDER_STATE_LOAN_SUCCESS}"  th:selected="${aduit.order_state==T(com.ddf.publics.tool.Constant).LOAN_ORDER_STATE_LOAN_SUCCESS}">已放款</option>
                                </select>
                            </div>
                            <div class="form-group col-3">
                                <label FOR="auditComment">审核备注</label>
                                <textarea name="auditComment" id="auditComment"  class="form-control">[[${aduit.audit_comment}]]</textarea>
                            </div>
                            <div th:if="${aduit.order_state !=  T(com.ddf.publics.tool.Constant).NLOAN_ORDER_STATE_CACEL}" class="form-group">
                                <label for="month" >审批金额(元):</label>
                                <input step="1" readonly th:if="${aduit.order_state > T(com.ddf.publics.tool.Constant).LOAN_ORDER_STATE_PASS }" name="maxMoney" class="form-control" th:value="${aduit.max_money}" type="number" id="max_money"  />
                                <input step="1" th:if="${aduit.order_state<=T(com.ddf.publics.tool.Constant).LOAN_ORDER_STATE_PASS }" name="maxMoney" class="form-control"  type="number" id="max_money"  />
                            </div>
                            <div class="form-group col-3">
                                <a th:if="${aduit.order_state==T(com.ddf.publics.tool.Constant).LOAN_ORDER_STATE_LOAN_SUCCESS}"  class="layui-btn layui-btn-disabled">已放款</a>
                                <a th:if="${aduit.order_state==T(com.ddf.publics.tool.Constant).NLOAN_ORDER_STATE_CACEL}"  class="layui-btn layui-btn-disabled">用户已取消</a>
                                <button th:if="${aduit.order_state!=T(com.ddf.publics.tool.Constant).LOAN_ORDER_STATE_LOAN_SUCCESS && aduit.order_state!=T(com.ddf.publics.tool.Constant).NLOAN_ORDER_STATE_CACEL}" type="submit" class="btn btn-primary mr-2">提交</button>
                                <a class="btn btn-light" th:href="@{/admin/audit}">取消</a>
                            </div>
                            <div class="form-group col-12" th:if="${aduit.loan_type!=T(com.ddf.publics.tool.Constant).LOAN_TYPE_XINYONG}">
                                <label for="Img" >抵押图片</label><br>
                                <img  disabled style="width:800px"   th:src="'/'+${aduit.Img}"  id="Img" >
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    function jiedai(){
        let state =  $("#orderState").val();
        let max_money =  $("#max_money").val();

        if(state==[[${T(com.ddf.publics.tool.Constant).LOAN_ORDER_STATE_PASS}]]){
            // isNaN()函数 把空串 空格 以及NUll 按照0来处理 所以先去除，
            if(max_money === "" || max_money ==null || isNaN(max_money)){
                layer.alert('请输入审批金额!才能通过!')
                return false;
            }
        }
        return true;
    }
</script>
</html>